package com.ruoyi.enterprise.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.enterprise.domain.ComHolderBefore10;
import com.ruoyi.enterprise.service.IComHolderBefore10Service;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 十大股东Controller
 * 
 * @author ruoyi
 * @date 2024-03-08
 */
@RestController
@RequestMapping("/enterprise/holder10")
public class ComHolderBefore10Controller extends BaseController
{
    @Autowired
    private IComHolderBefore10Service comHolderBefore10Service;

    /**
     * 查询十大股东列表
     */
    @PreAuthorize("@ss.hasPermi('enterprise:holder10:list')")
    @GetMapping("/list")
    public TableDataInfo list(ComHolderBefore10 comHolderBefore10)
    {
        startPage();
        List<ComHolderBefore10> list = comHolderBefore10Service.selectComHolderBefore10List(comHolderBefore10);
        return getDataTable(list);
    }

    /**
     * 导出十大股东列表
     */
    @PreAuthorize("@ss.hasPermi('enterprise:holder10:export')")
    @Log(title = "十大股东", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ComHolderBefore10 comHolderBefore10)
    {
        List<ComHolderBefore10> list = comHolderBefore10Service.selectComHolderBefore10List(comHolderBefore10);
        ExcelUtil<ComHolderBefore10> util = new ExcelUtil<ComHolderBefore10>(ComHolderBefore10.class);
        util.exportExcel(response, list, "十大股东数据");
    }

    /**
     * 获取十大股东详细信息
     */
    @PreAuthorize("@ss.hasPermi('enterprise:holder10:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(comHolderBefore10Service.selectComHolderBefore10ById(id));
    }

    /**
     * 新增十大股东
     */
    @PreAuthorize("@ss.hasPermi('enterprise:holder10:add')")
    @Log(title = "十大股东", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ComHolderBefore10 comHolderBefore10)
    {
        return toAjax(comHolderBefore10Service.insertComHolderBefore10(comHolderBefore10));
    }

    /**
     * 修改十大股东
     */
    @PreAuthorize("@ss.hasPermi('enterprise:holder10:edit')")
    @Log(title = "十大股东", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ComHolderBefore10 comHolderBefore10)
    {
        return toAjax(comHolderBefore10Service.updateComHolderBefore10(comHolderBefore10));
    }

    /**
     * 删除十大股东
     */
    @PreAuthorize("@ss.hasPermi('enterprise:holder10:remove')")
    @Log(title = "十大股东", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(comHolderBefore10Service.deleteComHolderBefore10ByIds(ids));
    }
}
